package com.sk.ccflower.lib.util.json;

import java.io.IOException;
import java.io.Writer;
import java.util.Collection;
import java.util.Iterator;

import com.sk.ccflower.lib.util.JSONUtil;

/**
 * <p>Java {@link Collection}으로 이루어진 JSON 배열을 나타내는 클래스.</p>
 * @author dagui
 *
 */
@SuppressWarnings("unchecked")
public class JSONCollection extends JSONObject implements Collection {

	private static final long serialVersionUID = -3750429445266078508L;
	
	private Collection collection;

	/*
	 * constructor
	 */

	public JSONCollection(Collection collection) {
		this.collection = collection;
	}
	
	/*
	 * implements JSONObject
	 */

	@Override
	public void writeJSON(Writer out) throws IOException {
		JSONUtil.writeJSON(collection, out);
	}

	@Override
	public Object getValue() {
		return collection;
	}
	
	/*
	 * implements java.util.Collection
	 */

	public boolean add(Object o) {
		return collection.add(o);
	}

	public boolean addAll(Collection c) {
		return collection.addAll(c);
	}

	public void clear() {
		collection.clear();
	}

	public boolean contains(Object o) {
		return collection.contains(o);
	}

	public boolean containsAll(Collection c) {
		return collection.containsAll(c);
	}

	public boolean isEmpty() {
		return collection.isEmpty();
	}

	public Iterator iterator() {
		return collection.iterator();
	}

	public boolean remove(Object o) {
		return collection.remove(o);
	}

	public boolean removeAll(Collection c) {
		return collection.removeAll(c);
	}

	public boolean retainAll(Collection c) {
		return collection.retainAll(c);
	}

	public int size() {
		return collection.size();
	}

	public Object[] toArray() {
		return collection.toArray();
	}

	public Object[] toArray(Object[] a) {
		return collection.toArray(a);
	}

}
